class Solution {
    public int findMin(int[] nums) {
        // nums[i] <= nums[nums.length - 1]
        // 3 4 5 1 2
        // 0 0 0 1 1
        // 4 5 6 7 0 1 2
        // 0 0 0 0 1 1 1
        int left = 0;
        int right = nums.length - 1;
        int last = nums[right];
        while (left < right) {
            int mid = (left + right) >> 1;
            if (nums[mid] <= last) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return nums[right];
    }
}
